package com.haipi.time;

import java.util.List;
import java.util.TimerTask;

import com.haipi.model.CommInitial;
import com.haipi.model.MailInfo;
import com.haipi.service.IMailService;
import com.haipi.util.mail.MailUtil;

public class CommTask extends TimerTask
{
	
	IMailService mailService ;
	
	public CommTask(IMailService mailService)
	{
		this.mailService = mailService;
	}

	@Override
	public void run()
	{
		List<MailInfo> mails = mailService.getSendMaiList();
		String key = "";
		for (int i = 0; i < mails.size(); i++)
		{
		    if ("0".equals(mails.get(i).getRemindType()))
		    {
		        key = "comm.remind";
		    }
		    else
		    {
		        key = "record.remind";
		    }
			MailUtil.send("沟通管理系统提示信息", (String)CommInitial.initialParamMap.get(key), mails.get(i).getAddressee());
			mailService.deleteMail(mails);
		}
	}

}
